package kr.hkit.powerjava.alone;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JTextField;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
import java.awt.CardLayout;

public class Test01Frame extends JFrame implements ActionListener {

	private JPanel contentPane;
	private Test01 panel;
	private JButton btnNewButton;
	private JLabel lblNewLabel;
	private JTextField ResultField;
	private JButton btnNewButton_1;
	private Test02 panel_1;
	private JLabel label;

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Test01Frame frame = new Test01Frame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public Test01Frame() {
		initialize();
	}

	private void initialize() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 256, 169);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

		panel = new Test01();
		contentPane.add(panel);

		btnNewButton_1 = new JButton("변환");
		btnNewButton_1.addActionListener(this);
		contentPane.add(btnNewButton_1);

		ResultField = new JTextField();
		contentPane.add(ResultField);
		ResultField.setColumns(20);

		/*
		 * panel_1 = new Test02(); contentPane.add(panel_1);
		 */

		label = new JLabel("");
		contentPane.add(label);
	}

	public void actionPerformed(ActionEvent e) {

		if (e.getActionCommand().equals("변환")) {
			int input = 0;
			try {
				input = Integer.parseInt(panel.getTextField().trim());

			} catch (NumberFormatException e1) {
				JOptionPane.showMessageDialog(this, "숫자만 입력하시오");
			}
			ResultField.setText(input + " 마일은 " + input * 1.6 + " 킬로미터입니다.");
			// panel_1.setTextField("마일은" + input*1.6+"킬로미터입니다.");
		}
	}
}
